%{
#include <stdlib.h>
#include <stdio.h>
#include "monsym.tab.h"
%}

%option yylineno
%x comment string defzero

%%

   /* Handle comments */
"/*"         BEGIN(comment);
<comment>[^*\n]*        /* eat anything that's not a '*' */
<comment>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
<comment>\n             /*++yylineno;*/
<comment>"*"+"/"        BEGIN(INITIAL);

#if[ ]*0  			BEGIN(defzero);
<defzero>#endif 	BEGIN(INITIAL);
<defzero>[^#] 		/* */

#define { return DEFINE; }

S_[A-Z_]+   {return MONNAME;}
DEF_[A-Z_]+  {yylval.s = strdup(yytext+4); return KEY;}
\'.\'|\'\\\'\'      {yylval.c = yytext[1]; return VAL;}
[0-9]+   {yylval.i = atoi(yytext); return INT;}
[ \t]+  /* eat */
\n      /* eat */
^[^#]       /* eat */
[^SD ][A-Z_]+ {return MISC;}
#ifndef[^\n]+  /* */
#endif[^\n]*   /* */
<<EOF>> {return THE_END;}
%%

int yywrap() {
 return 1;
}
